#ifndef _SINGLETON_H_
#define _SINGLETON_H_

/*
 *	<p>	Singleton Pattern </p>
 *	@author:	Kenvi.Luo
 *	@email:		kenvi.luo@gmail.com
 *	@date:		2007/08/06
 *	@modify:	N/A
 *	----------------------------
 *	@samples:
 *		using namepsace OPENPATTERN::PATTERN;
 *		SINGLETON(Manager).Func();
 *		SINGLETON_PTR(Manage)->Func();
 */

namespace FURY
{
	namespace PATTERN
	{
		#define SINGLETON(T)		Singleton<T >::getInstance()
		#define SINGLETON_PTR(T)	Singleton<T >::getInstancePtr()

		template<typename T>
		class Singleton
		{
			static T	_instance;
		public:
			Singleton()
			{
			};

			~Singleton()
			{
			};
			
			static T& getInstance()
			{
				return	_instance;
			};

			static T* getInstancePtr()
			{
				return &_instance;
			};
		};

		template<typename T> T Singleton<T>::_instance;
	};
};

#endif	//_SINGLETON_H_